package org.example.hansp.breakandcontinue;

import java.util.Scanner;

public class BreakExercise01 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String name;
        String password;
        int chances=3;
        for (int i = 0; i < chances; i++) {
            System.out.print("Enter your name: ");
            name = in.nextLine();
            System.out.print("Enter your password: ");
            password = in.nextLine();
            if("Lim".equals(name) && "niit*2022".equals(password)){
                System.out.println("You have successfully entered the name and password!");
                break;
            }

            if(chances-i-1==0){
                System.out.println("登录失败，请稍后重试");
            }else {
                System.out.println("登录失败");
                System.out.println("你还有" + (chances - i - 1) + "次机会，请重新输入用户名和密码");
            }
        }
    }
}
